<template>
  <div class="shopcar-container">
    <div class="mui-card" v-for="item in car" :key="item.id">
			<div class="mui-card-content">
				<div class="mui-card-content-inner">
          <mt-switch v-model="item.slected" @change="slected()"></mt-switch>
          <img :src="item.img_url" alt="">
          <div class="price-container">
            <h3 class="title">{{item.title}}</h3>
            <span class="price">￥{{item.price}}</span>
            <Numbox :item="item"/>
            <a href="#" class="del" @click.prevent="del(item.id)">删除</a>
          </div>
				</div>
			</div>
    </div>


    <div class="mui-card">
			<div class="mui-card-content">
				<div class="mui-card-content-inner">
					<div class="allprice">
            总计（不含运费）<br>
            已勾选商品<span> {{$store.getters.getCarNum}} </span>件，总价<span>￥{{$store.getters.getAllPrice}}</span>
          </div>
          <mt-button type="danger">去结算</mt-button>
				</div>
			</div>
    </div>
  </div>
</template>
<script>
import Numbox from '../components/numbox.vue'
export default {
  data(){
    return {
      car:this.$store.state.car.car,
    }
  },
  methods:{
    slected(){
      localStorage.setItem("car",JSON.stringify(this.car))
    },
    del(id){
      this.$store.commit("delShop",id)
    }

  },
  components:{
    Numbox
  }

}
</script>


<style lang="less" scoped>
.shopcar-container{
  overflow: hidden;
  background-color: #DDD;
  .mui-card .mui-card-content-inner{
    display: flex;
    flex-direction: row;
    align-items: center;
    img{
      width: 60px;
      height: 60px;
    }
    .price-container{
      .title{
        font-size: 16px;
        line-height: 20px;
      }
      .price{
        color:red;
        font-weight: bold;
      }
    }
  }
  .mui-card-content-inner{
    display: flex;
    justify-content: space-between;
  }
  .allprice{
    color:#333;
    span{
      color:red;
      font-weight: bold;
    }
  }
}
</style>
